<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup" lvKeepRequiredWidth>
    <lv-form-item class="mode-select">
        <lv-form-label lvRequired>
            {{'explore_share_protocol_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
            <lv-select formControlName="share_mode" [lvOptions]='sharedModeOptions' lvValueKey='value'
                lvMode="multiple">
            </lv-select>
        </lv-form-control>
    </lv-form-item>

    <!-- NFS -->
    <ng-container *ngIf="_includes(formGroup.value.share_mode, dataMap.Shared_Mode.nfs.value)">
        <div class="aui-gutter-column-sm aui-h3 share-title">
            {{dataMap.Shared_Mode.nfs.label | i18n}}
        </div>
        <lv-group lvGutter="36px" class="mode-group">
            <lv-form-column lvWidth="50%">
                <lv-form-item>
                    <lv-form-label lvRequired>
                        {{'protection_fqdn_ip_label' | i18n}}
                        <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_fqdn_ip_desc_label' | i18n}}"
                            class="configform-constraint" lvColorState='true'></i>
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]="ipNameErrorTip">
                        <input lv-input type="text" formControlName="nfs_ip" />
                    </lv-form-control>
                </lv-form-item>
            </lv-form-column>
            <lv-form-column lvWidth="50%">
                <lv-form-item>
                    <lv-form-label lvRequired>
                        {{'protection_clients_label' | i18n}}
                    </lv-form-label>
                    <lv-form-control>
                        <aui-agent-select [lvOptions]="nfsAgentOptions" formControlName="nfs_agents" lvValueKey="value"
                            lvMode="multiple">
                        </aui-agent-select>
                    </lv-form-control>
                </lv-form-item>
            </lv-form-column>
        </lv-group>
    </ng-container>

    <!-- CIFS -->
    <ng-container *ngIf="_includes(formGroup.value.share_mode, dataMap.Shared_Mode.cifs.value)">
        <div class="aui-gutter-column-sm aui-h3 share-title">
            {{dataMap.Shared_Mode.cifs.label | i18n}}
        </div>
        <lv-group lvGutter="36px" class="mode-group">
            <lv-form-column lvWidth="50%">
                <lv-form-item>
                    <lv-form-label lvRequired>
                        {{'protection_fqdn_ip_label' | i18n}}
                        <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_fqdn_ip_desc_label' | i18n}}"
                            class="configform-constraint" lvColorState='true'></i>
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]="ipNameErrorTip">
                        <input lv-input type="text" formControlName="cifs_ip" />
                    </lv-form-control>
                </lv-form-item>
                <!-- 认证模式 -->
                <lv-form-item>
                    <lv-form-label lvRequired>
                        {{'protection_auth_mode_label' | i18n}}
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
                        <lv-select formControlName="auth_mode" [lvOptions]='authOptions' lvValueKey='value'>
                        </lv-select>
                    </lv-form-control>
                </lv-form-item>
                <!-- NTLM认证 -->
                <ng-container *ngIf="formGroup.value.auth_mode === dataMap.Nas_Share_Auth_Mode.password.value">
                    <!-- 用户名 -->
                    <lv-form-item>
                        <lv-form-label lvRequired>
                            {{'common_username_label' | i18n}}
                            <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_nas_username_tip_label' | i18n}}"
                                class="configform-constraint" lvColorState='true'></i>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]="usernameErrorTip">
                            <input lv-input type="text" formControlName="username" />
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
                <!-- 协议加密 -->
                <lv-form-item>
                    <lv-form-label></lv-form-label>
                    <lv-form-control class="cifs-encryption">
                        <label lv-checkbox formControlName="encryption">
                            {{'protection_connect_mode_label' | i18n}}
                        </label>
                    </lv-form-control>
                </lv-form-item>
            </lv-form-column>
            <lv-form-column lvWidth="50%">
                <lv-form-item>
                    <lv-form-label lvRequired>
                        {{'protection_clients_label' | i18n}}
                    </lv-form-label>
                    <lv-form-control>
                        <aui-agent-select [lvOptions]="cifsAgentOptions" formControlName="cifs_agents" lvValueKey="value"
                            lvMode="multiple">
                        </aui-agent-select>
                    </lv-form-control>
                </lv-form-item>
                <!-- NTLM认证 -->
                <ng-container *ngIf="formGroup.value.auth_mode === dataMap.Nas_Share_Auth_Mode.password.value">
                    <lv-form-item>
                        <lv-form-label>{{'common_domain_label' | i18n}}</lv-form-label>
                        <lv-form-control [lvErrorTip]="domainNameErrorTip">
                            <input lv-input formControlName="domain_name" type="text" />
                        </lv-form-control>
                    </lv-form-item>
                    <lv-form-item>
                        <lv-form-label lvRequired>
                            {{'common_password_label' | i18n}}
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]="passwordErrorTip">
                            <aui-inupt-with-eye formControlName="password"
                                [lvPasteAllowed]="false"></aui-inupt-with-eye>
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
                <!-- kerberos认证 -->
                <lv-form-item *ngIf="formGroup.value.auth_mode === dataMap.Nas_Share_Auth_Mode.kerberos.value">
                    <lv-form-label lvRequired>
                        Kerberos
                    </lv-form-label>
                    <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
                        <lv-group lvGutter="8px">
                            <lv-select formControlName="kerberos" [lvOptions]='kerberosOptions' lvValueKey='kerberosId'
                                lvShowFilter lvFilterKey='label' lvFilterMode='contains'>
                            </lv-select>
                            <button lv-button (click)="createKerberos()" pmpermission pmOperation='CreateKerberos'>
                                {{ 'common_create_label' | i18n }}
                            </button>
                        </lv-group>
                    </lv-form-control>
                </lv-form-item>
            </lv-form-column>
        </lv-group>
    </ng-container>
</lv-form>
<div class="advanced-container">
    <aui-advanced-parameter [resourceData]="resourceData" [subResourceType]="dataMap.Resource_Type.NASShare.value"
        (statusChange)="advancedStatusChange($event)"></aui-advanced-parameter>
</div>